package com.study.lintcode.my.code_10;

/**********************************************************************
 * &lt;p&gt;文件名：Example_1.java &lt;/p&gt;
 * &lt;p&gt;文件描述：(https://www.lintcode.com/problem/a-b-problem/)
 * @project_name：LintCode
 * @author zengshunyao
 * @create 2019/1/5 21:56
 * @history
 * @department：政务事业部
 * Copyright ChengDu Funi Cloud Code Technology Development CO.,LTD 2014
 *                    All Rights Reserved.
 */
public class Example_8 {
    /**
     * @param str:    An array of char
     * @param offset: An integer
     * @return: nothing
     */
    public void rotateString(char[] str, int offset) {
        // write your code here
        if (str.length == 0) {
            return;
        }
        if (offset == 0) {
            return;
        }
        int i = (offset % str.length);
        int j = str.length - i;
        while (i-- != 0) {
            char ch = str[str.length - 1];
            for (int k = str.length - 1; k > 0; k--) {
                str[k] = str[k - 1];
            }
            str[0] = ch;
        }
    }


    public static void main(String[] args) {
        char arr[] = "abcdefg".toCharArray();
        new Example_8().rotateString(arr, 3);
        System.out.println(arr);
    }
}
